
# README

Replication Package for: A Meta-Analysis of Attitudes Towards Migrants and Displaced Persons
Authors: Sigrid Weber*, Nik Stoop, Peter van der Windt, and Haoyu Zhai (equal contribution)
Date: 9 October 2025

## Overview

This replication package contains all data and code required to reproduce the results reported in the BJPS paper A Meta-Analysis of Attitudes Towards Migrants and Displaced Persons.
The materials include R scripts for data preparation, main and supplemental analyses, and the machine-learning extension discussed in the Supplementary Information (SI Section D).

All code was written in R (≥ 4.3). Required R packages and dependencies are loaded at the beginning of each script. Users are advised to run the scripts sequentially in the order shown below.

## File Structure

### R Scripts

| File                                 | Description                                                                                                                                                                    |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| R_00_prepare_main_data_inputs.R      | Prepares individual-study–level data for analysis. Runs the main meta-analytic models, produces pooled estimates, and exports intermediate results used by subsequent scripts. |
| R_01_produce_main_text_outputs.R     | Generates all figures and tables reported in the main text of the paper.                                                                                                       |
| R_02_produce_appendix_outputs.R      | Produces figures and tables appearing in the Supplementary Information.                                                                                                        |
| R_supp_pilot_machine_learning.R      | Replicates the machine-learning analysis reported in SI Section D. This script is computationally intensive and may require extended runtime and memory resources.             |

### Data Files

| File                                                         | Description                                                                              |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| DAT_cleaned_study_data.csv                                   | Main cleaned dataset of individual study-level observations used in the meta-analysis.   |
| DAT_refugee_population.csv                                   | UNHCR country-level reports of forcibly displaced populations, 2000–2023.                |
| DAT_refugees_annual_population.csv                           | UNHCR global reports of total forcibly displaced populations, 2000–2023.                 |
| DAT_undesa_migrant_stock.xlsx                                | UNDESA reports of global migrant stocks, 1990–2020.                                      |
| DAT_undesa_pd_2020_ims_stock_by_sex_and_destination.xlsx     | UNDESA reports of migrant stocks by sex and destination, 1990–2020.                      |
| DAT_SCOPUS_LISTING.xlsx                                      | SCOPUS literature search results used to identify studies included in the meta-analysis. |

### Cached Machine-Learning Outputs

| File                               | Description                                                                                                                                                              |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| CACHE_cf_unemployed.rds            | Fitted causal forest for the focal predictor unemployed migrant (placeholder text file; full .rds too large to upload but available from authors on request).            |
| CACHE_cf_globalsouth.rds           | Fitted causal forest for the focal predictor migrant from the Global South (placeholder text file; full .rds too large to upload but available from authors on request). |
| CACHE_cf_tauhats_sub_unemp.csv     | Estimated causal effects from the fitted causal forest with unemployed migrant as the focal predictor.                                                                   |
| CACHE_cf_tauhats_sub_gs.csv        | Estimated causal effects from the fitted causal forest with Global South migrant as the focal predictor.                                                                 |
| CACHE_cf_vi_unemp.csv              | Variable-importance scores from the fitted causal forest with unemployed migrant as the focal predictor.                                                                 |
| CACHE_cf_vi_gs.csv                 | Variable-importance scores from the fitted causal forest with Global South migrant as the focal predictor.                                                               |

## Replication Instructions

1. Open the project directory in R (≥ 4.3).
2. Run scripts sequentially:

   R_00_prepare_main_data_inputs.R
   R_01_produce_main_text_outputs.R
   R_02_produce_appendix_outputs.R
   R_supp_pilot_machine_learning.R   # optional, heavy runtime

3. Output tables and figures will be saved automatically in the designated subfolders created by each script.

## Notes

* Machine-learning replication files are included for transparency but are not required to reproduce the core results.
* Minor rounding differences may occur across R versions or operating systems.

© 2025 The Authors.